<template>
	<view class="have-order">
		<view 
			class="order-item"
			v-for="(item,index) in dataList" 
			:key="index">
			<view class="title">
				<text class="num">订单号：{{item.order_no}}</text>
				<text class="iconfont icondelete" @click="delectIt(item.order_no)"></text>
			</view>
			<view class="order-detail">
				<view class="img-box">
					<image class="img" :src="item.product_id.image_url"></image>
				</view>
				<view class="text-detail">
					<view class="top-text">
						<text class="name">{{item.product_id.name}}</text>
						<text class="status" v-if="item.status == 1">交易成功</text>
						<text class="status red" v-if="item.status == 0">未支付</text>
					</view>
					<view class="center-text">
						<text class="num">共计{{item.quantity}}件</text>
						<text class="num">合计 ￥{{item.amount}}</text>
					</view>
				</view>
			</view>
			<view class="bottom-text">
				<text class="red" @click="topayment(item.product_id)">再次购买</text>
				<text class="grey" @click="linkDetail(item.product_id.id)">
					查看详情
				</text>
			</view>
		</view>
	</view>
</template>
<script>
 export default {
	name:"haveOrder",
	props:{
		dataList:{
			type:Array,
			default:[]
		}
	},
	methods:{
		delectIt(item){
			this.$alert({
				title:"提示",
				content:"是否删除，这条订单！"
			}).then(()=>{
				this.$emit("delectItme",item);
			}).catch(()=>{})
		},
		topayment(item){
			this.$store.commit("setgoodsData",item);
			this.$router({url:"../basic/payment"});
		},
		linkDetail(id){
			this.$router({url:`../basic/goodsdetail?id=${id}`})
		}
	}
 }
</script>
<style lang="scss" scoped>
	@import "../style/have_order.scss";
</style>
